import { request } from '@/utils/request'
// pc端固定客户端授权id
const clientId = import.meta.env.VITE_APP_CLIENT_ID

// 获取租户列表
export const getTenantList = () => request<any>('/auth/tenant/list', 'GET')

// 获取验证码
export const getCodeImg = () => request<any>('/auth/code', 'GET')

// 登录
export const login = (data: any, headers: any) =>
  request<any>(
    '/auth/login',
    'POST',
    {
      ...data,
      clientId: data.clientId || clientId,
      grantType: data.grantType || 'password'
    },
    {
      ...headers,
      isEncrypt: true
    }
  )
//单点登录
export const ssoLogin = (data: any) =>
  request<any>('/auth/ssoLogin', 'POST', data)

export const authBinding = (source: any, params: any) =>
  request<any>('/auth/binding/' + source, 'GET', params)

// 退出登录

export const logout = (obj: any) =>
  request<any>(`/auth/logout?source=${obj?.source}`, 'POST')

// 登录判断角色
// export const getUser = (userName: any) =>
//   request<any>(`/media/userInfo/detail?userName=${userName}`, 'GET')

// 登录获取路由
export const getRouters = () => request<any>(`/system/menu/getRouters`, 'GET')

// 获取角色
export const getUserInfo = () => request<any>(`/system/user/getInfo`, 'GET')

// 获取租户的logo/标题
export const getTenant = (tenantId: any) =>
  request<any>(`/system/tenant/queryByTenantId?tenantId=${tenantId}`, 'GET')
